#include <stdio.h>
#include <string.h>     //strcpy函数
#include <malloc.h>
struct Student
{
    char name[20];
    int score;
    struct Student *next;
};

int Get_maxScore(struct Student *head,char number1[20])
{
    int max_score;
    max_score = head->score;
    struct Student *p;
    strcpy(number1,head->name);
    p = head;
    while(p != NULL)
    {
        if(p->score > max_score)
        {
            max_score = p->score;
            strcpy(number1,p->name);
        }
        p = p->next;
    }
    return max_score;
}

int main()
{
    int Max_score;
    char number1[20];
    //创建静态链表
    // struct Student a,b,c,*head,*p;
    // scanf("%s %d",a.name,&a.score);
    // scanf("%s %d",b.name,&b.score);
    // scanf("%s %d",c.name,&c.score);
    // head = &a;
    // a.next = &b;
    // b.next = &c;
    // c.next = NULL;
    int n = 0,i = 0;
    struct Student *head = malloc(sizeof(struct Student));
    struct Student *p;
    p = head;
    scanf("%d",&n);
    scanf("%s",p->name);
    scanf("%d",&(p->score));
    for(i = 0;i<(n-1);i++)
    {
        p->next = malloc(sizeof(struct Student));
        scanf("%s",p->next->name);
        // printf("%s",p->next->name);
        scanf("%d",&(p->next->score));
        p->next->next = NULL; //给新增结点做尾结点
        p = p->next; //往后走
    }
    Max_score = Get_maxScore(head,number1);
    printf("%s %d",number1,Max_score);

}
